package com.lqwu.mallchatserver.user.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Description: 用户状态枚举
 * Author: <a href="https://github.com/zongzibinbin">abin</a>
 * Date: 2023-03-19
 */
@AllArgsConstructor
@Getter
public enum UserStatusEnum {
    NORMAL(0, "正常"),
    BLACK(1, "拉黑"),
    ;

    private final Integer id;
    private final String desc;

    private static Map<Integer, UserStatusEnum> cache;

    static {
        cache = Arrays.stream(UserStatusEnum.values()).collect(Collectors.toMap(UserStatusEnum::getId, Function.identity()));
    }

    public static UserStatusEnum of(Long type) {
        return cache.get(type);
    }
}
